package www.woniuxy.com.class112.controller;

import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import www.woniuxy.com.class112.form.specialEnvoySignInForm;
import www.woniuxy.com.class112.param.specialEnvoySignInParam;
import www.woniuxy.com.class112.service.WorkOrderDetailsService;
import www.woniuxy.com.class112.util.JwtUtil;
import www.woniuxy.com.class112.util.Result;

import javax.annotation.Resource;

@RestController
@RequestMapping("/workOrderDetails")
@Api("特派员签到")
public class WorkOrderDetailsController {
    @Resource
    private WorkOrderDetailsService workOrderDetailsService;

    @PostMapping("/specialEnvoySignIn")
    @ApiOperation("特派员签到")
    public Result specialEnvoySignIn(@RequestBody specialEnvoySignInForm form,@RequestHeader String token) throws Exception {
        Long agentId = JwtUtil.getUserId(token);
        specialEnvoySignInParam param = BeanUtil.toBean(form, specialEnvoySignInParam.class);
        param.setAgentId(agentId);
        workOrderDetailsService.specialEnvoySignIn(param);
        return Result.success("特派员签到成功",null);
    }
}
